// releasePage/pages/homePageInfo/description/description.js
const app = getApp();
Page({
    /**
     * 页面的初始数据
     */
    data: {
        ipxBottom: 0,
        current: Number,
        descriptionValue: '',
        descriptionlength: 0,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.setData({
            current: options.current,
            descriptionValue: options.description,
            descriptionlength: options.description.length,
        });
        if (app.globalData.isIpx) {
            this.setData({
                ipxBottom: 34,
            });
        }
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {},
    description: function (e) {
        this.setData({
            descriptionValue: e.detail.value,
            descriptionlength: e.detail.value.length,
        });
        app.numLimitTip(e.detail.value.length, 500);
    },
    backTap(e) {
        if (this.data.descriptionValue) {
            let pages = getCurrentPages();
            let prevPage = pages[pages.length - 2];
            if (this.data.current == 0) {
                prevPage.setData({
                    ftDiscription: this.data.descriptionValue,
                });
            } else if (this.data.current == 1) {
                prevPage.setData({
                    ftLineDiscription: this.data.descriptionValue,
                });
            } else if (this.data.current == 2) {
                prevPage.setData({
                    nfcDiscription: this.data.descriptionValue,
                });
            } else {
                prevPage.setData({
                    nfcLineDiscription: this.data.descriptionValue,
                });
            }
            wx.navigateBack({
                delta: 1, // 返回上一级页面。
            });
        } else {
            wx.showToast({
                title: '请将信息填写完整',
                icon: 'none',
                duration: 1500,
            });
        }
    },
});
